package com.bluesky.log;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

@Component
public class UserNameInterceptor implements HandlerInterceptor {

    @Autowired
    private IUserNameProvider userNameProvider;

    @Override
    public boolean preHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler) throws Exception {
        /*String userName = request.getHeader("userName");
        userNameProvider.setUserName(userName);
        return true;*/
         //这里从请求中得到用户名，然后塞到userNameProvider中
        String userName = "路人";
        this.userNameProvider.setUserName(userName);
        return HandlerInterceptor.super.preHandle(request, response, handler);
    }
}
